package com.atguigu.dw.gmallpublisher.service.impl;

import com.atguigu.dw.gmallpublisher.mapper.DauMapper;
import com.atguigu.dw.gmallpublisher.service.DauServeice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author ：剧情再美终是戏
 * @description：查询日活数据服务层接口实现类
 * @mail : 13286520398@163.com
 * @date ：Created in 2020/2/12 12:29
 * @modified By：
 * @version: 1.0$
 */
@Service
public class DauServiceImpl implements DauServeice {

    @Autowired
    DauMapper dauMapper;

    @Override
    public Long getDauTotal(String date) {
        return dauMapper.getDauTotal(date);
    }

    @Override
    public Map<String, Long> getRealtimeHour(String date) {

        // 定义返回结果
        Map<String, Long> result = new HashMap<>();

        // 获取数据层结果
        List<Map> realtimeHour = dauMapper.getRealtimeHour(date);

        // 转换数据
        for (Map map : realtimeHour) {
            result.put("" + map.get("LOGHOUR"), Long.parseLong("" + map.get("COUNT")));
        }
        return result;
    }
}
